home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
007
/
ptool.arc
/
PTOOLSCR.INC
< prev
next >
Wrap
Text File
|
1985-06-06
|
12KB
|
295 lines
{ PTOOLSCR.INC Copyright 1985 R D Ostrander Version 1.0
Ostrander Data Services
5437 Honey Manor Dr
Indianapolis IN 46241
This Turbo Pascal function is a record oriented data entry tool used to
automate the programming effort involved in setting up operator editting
screen. It uses PTOOLENT to allow entry of each field; PTOOLENT.INC must be
included in the calling program before PTOOLSCR.INC.
This program has been placed in the Public Domain by the author and copies
may be freely made for non-commercial, demonstration, or evaluation purposes.
Use of these subroutines in a program for sale or for commercial purposes in
a place of business requires a $20 fee be paid to the author at the address
above. Personal non-commercial users may also elect to pay the $20 fee to
encourage further development of this and similar programs. With payment you
will be able to receive update notices, diskettes and printed documentation
of this and other PTOOLs from Ostrander Data Services.
PTOOL, and PTOOLxxx are Copyright Trademarks of Ostrander Data Services
Turbo Pascal is a Copyright of Borland International Inc.
Usage of this procedure is as follows:
1) Code Record area for operator editting.
2) Include PTOOLENT.INC in your calling program.
3) Include PTOOLSCR.INC in your calling program.
4) Create the Field Table constants necessary for the PTOOLSCR procedure
call. The PTOOLSCR_Field_Array type is laid out below.
These first 4 steps must be done while writing your program.
The next 3 steps are program actions during execution.
5) Fill the Record area with the data to be presented to the operator at
the beginning of the edit.
6) Call PTOOLSCR.
7) Recieve the changed data in the Record area and the Return Code and
Last Field from PTOOLSCR.
The screen is first painted with description and display information; then
the fields are presented to the operator in field table order who may edit
fields according to the rules of PTOOLENT and may move between fields by
the following actions:
C/R, <Ctrl-N>, <Ctrl-Q> - Moves to the next field until, after the
Filled Field, Down Arrow last field a Return Code of 1 is passed
back to the calling program.
Home - Returns to editting the first field.
Up Arrow - Returns to editting the previous field.
End - Moves to edit the last field.
Any other special key such as the Function Keys, PgUp, PgDn, etc will end
the screen editting and pass back the Return Code as per PTOOLENT.
The data may be presented to the operator in "Display only" mode by putting
a 'D' in the Display_Only parameter before the call. Control will immediately
be passed back to the calling program.
The screen painting may be eliminated on the second and subsequent call with
the same record type by putting a 'N' in the Screen_Paint parameter before
the call. This will make your program appear much "snappier".
Watch out that the following items are carefully handled:
> The X/Y coorodinates, Relative record position, Display size parameters
in the Field Table must have leading zeroes.
> The Relative record position in the Field Table must be accurate, having
any bad numbers here will cause you monumental headaches during testing
since you may be displaying character or string data as integers, bytes
or reals. This is the first place to look if PTOOLSCR doesn't seem to be
working right.
> Record information must be correct before calling PTOOLSCR. This applies
to string data. If these fields aren't initialized, strange results may
happen.
}
{ Type value for inclusion in the calling program's Field Table is here for
convenience only. String [55] will work just as well. }
TYPE
PTOOLSCR_Field_Array = String [55];
{ Char 1 = Field Type B = Byte - 1 byte
C = Char - 1 byte
D = Dummy - for display text only.
no data editted
M = Message - for display and
message text only.
string data that is
not editted
I = Integer - 2 bytes
R = Real - 6 bytes
S = String - String length
plus 1 byte
Char 2-3 = X position of display text
Char 4-5 = Y position of display text
Char 6-45 = Up to 40 characters of display text
Char 46-48 = 1 relative position of field in record
Char 49-50 = X position of field display verbage
Char 51-52 = Y position of field display verbage
Char 53-54 = Display size of field
Char 55 = Number of decimal places for field type R }
{ Called Procedure Begins Here ******************************************** }
Procedure PTOOLSCR (VAR Record_Area,
Table_Area;
Num_Fields : Integer;
VAR ReturnCode : Integer;
VAR LastField : Integer;
Display_Only : Char;
Paint_Screen : Char;
First_Field : Integer);
VAR
I : Integer;
RecChar : Array [1..2] of Char absolute Record_Area;
Table : Array [1..2] of PTOOLSCR_Field_Array absolute Table_Area;
TableHold : PTOOLSCR_Field_Array;
WorkArea : String [80];
WByte : Byte Absolute WorkArea;
WInteger : Integer Absolute WorkArea;
WReal : Real Absolute WorkArea;
XorkArea : String [80];
XByte : Byte Absolute XorkArea;
XInteger : Integer Absolute XorkArea;
XReal : Real Absolute XorkArea;
TypeData : Char;
DescX, DescY : Byte;
Desc : String [40];
Position : Integer;
DispX, DispY : Byte;
DispSize : Integer;
Decimals : Integer;
EditType : Char;
SpaceString : String [80];
Procedure Set_Table (I : Integer);
Var
TableEntry : PTOOLSCR_Field_Array;
TableChar : Array [1..55] of Char absolute TableEntry;
X : Byte;
Begin
TableEntry := Table [I];
TypeData := TableChar [2];
DescX := ((Ord (TableChar [3]) - 48) * 10)
+ (Ord (TableChar [4]) - 48);
DescY := ((Ord (TableChar [5]) - 48) * 10)
+ (Ord (TableChar [6]) - 48);
Move (TableChar [7], Desc [1], 40);
X := 40;
While (Desc [X] = ' ') and (X > 1) do
X := X - 1;
Desc [0] := Char (X);
Position := ((Ord (TableChar [47]) - 48) * 100)
+ ((Ord (TableChar [48]) - 48) * 10)
+ (Ord (TableChar [49]) - 48);
DispX := ((Ord (TableChar [50]) - 48) * 10)
+ (Ord (TableChar [51]) - 48);
DispY := ((Ord (TableChar [52]) - 48) * 10)
+ (Ord (TableChar [53]) - 48);
DispSize := ((Ord (TableChar [54]) - 48) * 10)
+ (Ord (TableChar [55]) - 48);
Decimals := (Ord (TableChar [56]) - 48);
End;
BEGIN
For I := 1 to 80 do
SpaceString [I] := ' ';
If Paint_Screen <> 'X' then For I := 1 to Num_Fields do
Begin
Set_Table (I);
If (Paint_Screen <> 'N') and (Desc <> ' ') then
Begin
Gotoxy (DescX, DescY);
Write (Desc);
End;
If TypeData <> 'D' then
Begin
Move (RecChar [Position], WorkArea [0], 81);
Gotoxy (DispX, DispY);
Case TypeData of
'B' : Write (Wbyte:DispSize);
'C' : Write (RecChar [Position]);
'I' : Write (WInteger:DispSize);
'R' : Write (WReal:DispSize:Decimals);
'M' : Begin
SpaceString [0] := Char (DispSize);
Write (SpaceString);
Gotoxy (DispX, DispY);
Write (WorkArea);
End;
'S' : Write (WorkArea);
End; {Case}
End;
End;
If not (Display_Only in ['D', 'M']) then
Begin
I := First_Field;
While I <= Num_Fields do
Begin
Set_Table (I);
If TypeData in ['D', 'M'] then
I := I + 1
else
Begin
Move (RecChar [Position], WorkArea [0], 81);
Gotoxy (DispX, DispY);
EditType := TypeData;
Case TypeData of
'B' : Begin
EditType := 'I';
XInteger := WByte;
End;
'C' : Begin
XorkArea [1] := RecChar [Position];
XorkArea [0] := Char (1);
EditType := 'S';
End;
'I' : Xinteger := WInteger;
'R' : XReal := WReal;
'S' : XorkArea := WorkArea;
End; {Case}
PTOOLENT (XorkArea,
EditType,
DispSize,
Decimals,
ReturnCode);
LastField := I;
Case TypeData of
'B' : Begin
WByte := XInteger;
Move (WByte, RecChar [Position], 1);
End;
'C' : Move (XorkArea [1], RecChar [Position], 1);
'I' : Move (XorkArea, RecChar [Position], 2);
'R' : Move (XorkArea, RecChar [Position], 6);
'S' : Move (XorkArea, RecChar [Position],
Ord (XorkArea [0]) + 1);
End; {Case}
Case ReturnCode of
1, 2, 80 : Begin
I := I + 1;
ReturnCode := 1;
End;
71 : I := 1;
72 : Begin
I := I - 1;
TableHold := Table [I];
While (I >= 1) and (TableHold [1] in ['D', 'M']) do
Begin
I := I - 1;
TableHold := Table [I];
End;
If I <= 0 then I := 1;
End;
79 : Begin
I := Num_Fields;
TableHold := Table [I];
While (I >= 1) and (TableHold [1] in ['D', 'M']) do
Begin
I := I - 1;
TableHold := Table [I];
End;
If I <= 0 then I := 1;
End;
else I := Num_Fields + 1;
End; {Case}
End;
End;
End;
END;